# -*- coding: utf-8 -*-

import py_global
import logging

from redis import Redis
from redis.sentinel import Sentinel

logger = logging.getLogger(__name__)

if __name__ == '__main__':
    master_name = ''
    password = ''
    host_port = 'host1:26379,host2:26379,host3:26379'
    node_list = list()
    for node in host_port.split(','):
        for host, port in node:
            node_tuple = (host, int(port))
            node_list.append(node_tuple)

    redis_sentinel = Sentinel(node_list)
    redis_master: Redis = redis_sentinel.master_for(service_name=master_name, password=password)

    redis_slave: Redis = redis_sentinel.slave_for(service_name=master_name, password=password)
